home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 3 / adb / g-io < prev    next >
Text File  |  1996-02-12  |  4KB  |  136 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                              G N A T . I O                               --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.6 $                              --
  10. --                                                                          --
  11. --     Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc.     --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. package body GNAT.IO is
  37.  
  38.    ---------
  39.    -- Get --
  40.    ---------
  41.  
  42.    procedure Get (X : out Integer) is
  43.  
  44.       function Get_Int return Integer;
  45.       pragma Import (C, Get_Int, "get_int");
  46.  
  47.    begin
  48.       X := Get_Int;
  49.    end Get;
  50.  
  51.    procedure Get (C : out Character) is
  52.  
  53.       function Get_Char return Character;
  54.       pragma Import (C, Get_Char, "get_char");
  55.  
  56.    begin
  57.       C := Get_Char;
  58.    end Get;
  59.  
  60.    --------------
  61.    -- Get_Line --
  62.    --------------
  63.  
  64.    procedure Get_Line (Item : in out String; Last : out Natural) is
  65.       I_Length : Integer := Item'Length;
  66.       Nstore   : Integer := 0;
  67.       C        : Character;
  68.  
  69.    begin
  70.       loop
  71.          Get (C);
  72.          exit when Nstore = I_Length;
  73.  
  74.          if C = Ascii.LF then
  75.             exit;
  76.          end if;
  77.  
  78.          Item (Item'First + Nstore) := C;
  79.          Nstore := Nstore + 1;
  80.       end loop;
  81.  
  82.       Last := Item'First + Nstore - 1;
  83.    end Get_Line;
  84.  
  85.    --------------
  86.    -- New_Line --
  87.    --------------
  88.  
  89.    procedure New_Line (Spacing : Positive := 1) is
  90.    begin
  91.       for J in 1 .. Spacing loop
  92.          Put (Ascii.LF);
  93.       end loop;
  94.    end New_Line;
  95.  
  96.    ---------
  97.    -- Put --
  98.    ---------
  99.  
  100.    procedure Put (X : Integer) is
  101.  
  102.       procedure Put_Int (X : Integer);
  103.       pragma Import (C, Put_Int, "put_int");
  104.  
  105.    begin
  106.       Put_Int (X);
  107.    end Put;
  108.  
  109.    procedure Put (C : Character) is
  110.  
  111.       procedure Put_Char (C : Character);
  112.       pragma Import (C, Put_Char, "put_char");
  113.  
  114.    begin
  115.       Put_Char (C);
  116.    end Put;
  117.  
  118.    procedure Put (S : String) is
  119.    begin
  120.       for J in S'Range loop
  121.          Put (S (J));
  122.       end loop;
  123.    end Put;
  124.  
  125.    --------------
  126.    -- Put_Line --
  127.    --------------
  128.  
  129.    procedure Put_Line (S : String) is
  130.    begin
  131.       Put (S);
  132.       New_Line;
  133.    end Put_Line;
  134.  
  135. end GNAT.IO;
  136.